package top.wyix.module.bpm.service.task;

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService;
import org.flowable.engine.history.HistoricActivityInstance;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import top.wyix.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO;
import top.wyix.module.bpm.convert.task.BpmActivityConvert;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wangdx
 */
@Service
@Slf4j
@Validated
public class BpmActivityServiceImpl implements BpmActivityService{
    @Resource
    private HistoryService historyService;

    @Override
    public List<BpmActivityRespVO> getActivityListByProcessInstanceId(String processInstanceId) {
        List<HistoricActivityInstance> activityList = historyService.createHistoricActivityInstanceQuery()
                .processInstanceId(processInstanceId).list();
        return BpmActivityConvert.INSTANCE.convertList(activityList);
    }

    @Override
    public List<HistoricActivityInstance> getHistoricActivityListByExecutionId(String executionId) {
        return historyService.createHistoricActivityInstanceQuery().executionId(executionId).list();
    }

}
